import { useEffect, useState } from 'react';
//闭包陷阱
function Five() {
  const [count, setCount] = useState(0);
  useEffect(() => {
    console.log(count); //用到了外面的count,形成了闭包

    setInterval(() => {
      setCount((count) => count + 1);
    }, 1000);
  }, []);
  return (
    <>
      <div>{count}</div>
    </>
  );
}
export default Five;
